package reflection;

interface Waterproof {
}

interface Shoots {
}

class Toy {
    Toy() {
    }

    Toy(int i) {
    }
}

class FancyToy extends Toy implements Waterproof, Shoots {
    FancyToy() {
        super(1);
    }
}

public class ToyTest {
    static void printinfo(Class cc) {
        System.out.println("Class name:" + cc.getName() + " is interface ? [" + cc.isInterface() + "]" + "   SimpleName:" + cc.getSimpleName() + "   CanonicalName:" + cc.getCanonicalName());
    }

    public static void main(String[] args) {
        Class c = null;
        try {
            c = Class.forName("reflection.FancyToy");
        } catch (ClassNotFoundException e) {
            System.out.println("Can't find FancyToy");
            System.exit(1);
        }
        printinfo(c);
        for (Class face : c.getInterfaces())
            printinfo(face);
        Class parent = c.getSuperclass();
        Object obj = null;
        try {
            obj = parent.newInstance();
        } catch (InstantiationException e) {
            System.out.println("Can't instance");
            System.exit(1);
        } catch (IllegalAccessException e) {
            System.out.println("Can't access");
            System.exit(1);
        }
        printinfo(obj.getClass());
    }
}
